﻿using System.Collections.Generic;
using IchiaTester.Utils;

namespace IchiaTester
{
    /// <summary>
    /// 用户实体类
    /// </summary>
    public class UserInfo
    {
        public string FactoryName { get; set; }
        public string HashPassword { get; set; }
        public string Permission { get; set; }
    }

    /// <summary>
    /// 系统常量
    /// </summary>
    public static class SystemSetting
    {
        /// <summary>
        /// 软件名
        /// </summary>
        public const string SOFTWARE_NAME = "IchiaTester";

        /// <summary>
        /// 软件版本
        /// </summary>
        public const string SOFTWARE_VERSION = "2.3";

        /// <summary>
        /// 发行日期
        /// </summary>
        public const string RELEASE_DATE = "2025/01/17";

        /// <summary>
        /// 存配置文件名
        /// </summary>
        public const string SETTING_FILENAME = "IchiaTester.ini";

        /// <summary>
        /// 测试结果文件名
        /// </summary>
        public const string TEST_RESULT_FILENAME = "testresults.xml";

        /// <summary>
        /// 存储用户文件名
        /// </summary>
        public const string USER_INFO_FILENAME = "User.xml";

        /// <summary>
        /// 测试默认文件名
        /// </summary>
        public const string TEST_CFG_DEFAULT_FILENAME = "IchiaTester.cfg";

        public const string TEST_TYPE_CFG_FILENAME = "TestType.cfg";
        public const string COMMU_CONFIG_TYPE_CFG_FILENAME = "CommuType.cfg";
        public const string TEST_PARAM_TYPE_CFG_FILENAME = "TestParamType.cfg";

        /// <summary>
        /// 串口配置文件名
        /// </summary>
        public const string SERIAL_PORT_CONFIG_FILENAME = "SerialPortConfig.cfg";

        /// <summary>
        /// 波形图配置文件名
        /// </summary>
        public const string VISUALIZER_CFG_FILENAME = "VisualizerConfig.cfg";

        /// <summary>
        /// 超级用户名
        /// </summary>
        public const string SUPER_USER = "Admin";

        /// <summary>
        /// 超级用户密码
        /// </summary>
        public const string SUPER_USER_PW = "Admin";

        //ini or xml
        public static string INI_SECTION_SYS_SETTING = "SYSTEM_SETTING";
        public static string INI_SECTION_AVERAGE_SETTING = "AVERAGE_SETTING";
        public static string INI_SECTION_TEST_INIT_SETTING = "TEST_INIT_SETTING";

        #region System Setting

        public const string WORKER_ID = "WORKER_ID"; //工號
        public const string WORK_SHIFT = "WORK_SHIFT"; //班別
        public const string PRODUCT_ID = "PRODUCT_ID"; //產品編號
        public const string WORK_ORDER = "WORK_ORDER"; //工單號
        public const string PROCESS_ORDER = "PROCESS_ORDER"; //製程編號
        public const string BOARD_NUM = "BOARD_NUM"; //多版數
        public const string PRODUCT_KEY = "PRODUCT_KEY"; //產品key
        public const string JIG_ID = "JIG_ID"; //治具編號
        public const string MACHINE_ID = "MACHINE_ID"; //機器編號
        public const string APP_NAME = "APP_NAME"; //程式名稱
        public const string APP_VERSION = "APP_VERSION"; //版本
        public const string BARCODE_LENGTH = "BARCODE_LENGTH"; //Barcode長度
        public const string DELAY_TO_TEST = "DELAY_TO_TEST"; //掃瑪後啟動測試
        public const string DELAY_TO_WAIT = "DELAY_TO_WAIT"; //測試結束測試解果返回WAIT時間
        public const string CLEAR_AFTER_TEST = "CLEAR_AFTER_TEST";

        public const string FACTORY_LOG_PATH = "FACTORY_LOG_PATH"; //log path
        public const string APP_LOG_PATH = "APP_LOG_PATH";
        public const string TEST_CFG_PATH = "TEST_CFG_PATH"; //test case cfg file path
        public const string BEFORE_TEST_CASE_PATH = "BEFORE_TEST_CASE_PATH"; //before test case path
        public const string AFTER_TEST_CASE_PATH = "AFTER_TEST_CASE_PATH"; //after test case path

        //System parameter

        public static string workId; //工號
        public static string workShift; //班別
        public static string productId; //產品編號
        public static string workOrder; //工單號
        public static string processOrder; //製程編號
        public static string boardNum; //多版數
        public static string multiBoardResult; //多板結果
        public static string multiBoardRetry; //多板重測
        public static string productkey; //產品key
        public static string jigId; //治具編號
        public static string machineId; //機器編號
        public static string appName; //程式名稱
        public static string appVersion; //版本
        public static string delayToStartTest; //掃瑪後延遲啟動測試 ,unit:sec
        public static string delayToWait; //測試結束測試解果返回WAIT時間,unit: sec
        public static string clearAfterTest;
        public static string resultDetail; //詳細結果


        //path 文件路径
        public static string testResultPath; // 测试结果路径
        public static string userInfoPath; // 用户信息文件路径
        public static string serialPortConfigPath; // 串口配置信息路径
        public static string defaultAppLogPath; // app默认日志路径
        public static string iniFilePath; // ini 格式配置文件

        public static string appLogPath; // app日志路径
        public static string testCasePath; // 测试项目路径
        public static string beforeTestCasePath;
        public static string afterTestCasePath;
        public static string factoryLogPath;
        public static string appLogFilename; // app日志名

        //tpTestInit
        public static string keepTestCheck;
        public static string startButtonCheck;
        public static string barcodeDetectCheck; // 扫码枪功能开启状态
        public static string deviceCMDCheck;
        public static string barcodeLength; //Barcode長度
        public static string askDeviceCheck;
        public static string askDeviceCMD;
        public static string askDevicePort;
        public static string askDeviceFreq;
        public static string askDeviceReturnPort;
        public static string askDeviceReturnCMD;
        public const string KEEP_TEST_CHECK = "KEEP_TEST_CHECK";
        public const string START_BUTTON_CHECK = "START_BUTTON_CHECK";
        public const string BARCODE_DETECT_CHECK = "BARCODE_DETECT_CHECK";
        public const string DEVICE_CMD_CHECK = "DEVICE_CMD_CHECK";
        public const string ASK_DEVICE_CHECK = "ASK_DEVICE_CHECK";
        public const string ASK_DEVICE_CMD = "ASK_DEVICE_CMD";
        public const string ASK_DEVICE_PORT = "ASK_DEVICE_PORT";
        public const string ASK_DEVICE_FREQ = "ASK_DEVICE_FREQ";
        public const string ASK_DEVICE_RETURN_PORT = "ASK_DEVICE_RETURN_PORT";
        public const string ASK_DEVICE_RETURN_CMD = "ASK_DEVICE_RETURN_CMD";

        #endregion


        #region Average Setting 平均值设置

        public const string AVERAGE_SETTING = "AVERAGE_SETTING";

        public static string averageSetting;
        public static string AVERAGE_STR;

        #endregion


        //user info
        public static bool isAdmin; // 登录用户是否是超级用户

        public static bool isEngineer; // 登录用户是否是工程师

        /// <summary>
        /// 用户信息字典 key:用户名 userName value:UserInfo
        /// </summary>
        public static Dictionary<string, UserInfo> UserInfoDict = new Dictionary<string, UserInfo>();

        public static string loginUserName; //登入用戶名稱

        //For search comport 可用串口的端口号集合
        public static List<string> availablePorts = SerialPortHandler.GetAvailableComPorts();


        //barcode 条形码相关
        public static string previousBarCode; // 之前的条形码
        public static string barCode; // (当前的)条形码
        public static string BarCodeFilename; // 条形码文件名

        //user level 用户级别
        public static int PERMISSION_LV_ADMIN = 0;
        public static int PERMISSION_LV_ENGINEER = 1;
        public static int PERMISSION_LV_USER = 2;

        //Test Case Type
        public const int TYPE_DEVICE_CMD = 11;
        public const int TYPE_PASS_DEVICE_CMD = 12;
        public const int TYPE_FAIL_DEVICE_CMD = 13;
    }

    /// <summary>
    /// 系统信息
    /// </summary>
    public static class System_msg
    {
        public const string LOADING = "Loading ...";
        public const string ERROR = "error";
        public const string LOAD_SUCCESS = "Loading success";
        public const string PLS_SELET_COM = "Please select COM port !!\r\n";
        public const string COM_ALREADY_OPEN = "COM port already open !!\r\n";
        public const string COM_NOT_OPEN = "Comport is not open !!\r\n";
        public const string TTE_NOT_FOUND = "Can not find TTE, Please check the setting";
        public const string CFG_FILE_NOT_EXIST = "CFGis not exist , Please check the setting!";
        public const string BARCODE_EMPTY = "Barcode is empty!";

        /*
         * 用于展示状态的字符串
         */
        public const string PASS_STR = "PASS"; // 检测通过字符串
        public const string FAIL_STR = "FAIL"; // 检测失败字符串
        public const string STOP_STR = "STOP"; // 检测停止字符串
        public const string WAIT_STR = "WAIT"; // 等待检测字符串
        public const string CHECK_SERIAL_PORT = "請檢查串口"; // 请检查串口字符串
        public const string NEED_LOGIN_STR = "請先登入"; // 请先登入字符串
        public const string NO_LOGIN_STR = "未登入"; // 未登入字符串
        public const string TIMEOUT_STR = "TIMEOUT"; // 超时字符串
        public const string RETRY_STR = "RETRY"; // 重试字符串
        public const string TOTAL_STR = "TOTAL"; // 总数字符串

        public const string PERCETNAGE_STR = "良率";

        public const string LOGIN_USER_STR = "登入用戶";
        public const string WORKER_ID_STR = "工號";
        public const string WORK_SHIFT_STR = "班別";
        public const string PRODUCT_ID_STR = "產品編號";
        public const string WORK_ORDER_STR = "工單號";
        public const string PROCESS_ORDER_STR = "製程編號";
        public const string BOARD_NUM_STR = "多版數";
        public const string JIG_ID_STR = "治具編號";
        public const string MACHINE_ID_STR = "機器編號";
        public const string APP_NAME_STR = "程式名稱";
        public const string APP_VERSION_STR = "版本";

        //Result message 结果展示信息常量
        public const string PROG1 = "Renesas Prog";
        public const string PROG2 = "Atmel Prog";
        public const string TESTING_STR = "Testing...";
        public const string RESURLT_STR = "結果";
        public const string SKIP_STR = "Skip";
        public const string PROCESSED_STR = "PROCESSED";

        //App Log message app的日志信息常量
        public const string LOG_ERROR = "Error";
        public const string LOG_WARNING = "Warning";
        public const string LOG_INFO = "Info";
        public const string LOG_LOADING = "Try to load Data: ";
        public const string LOG_LOAD_SUCCESS = "Successfully loaded Data: ";
        public const string LOG_LOAD_FAIL = "Failed to load Data: ";
        public const string LOG_SAVING = "Try to save data: ";
        public const string LOG_SAVE_SUCCESS = "Successfully saved Data: ";
        public const string LOG_SAVE_FAIL = "Failed to save Data: ";
        public const string LOG_SEPARATOR = "------------------------------------------------------------";
    }
}